# -*-coding:utf-8 -*-
from rest_framework.views import exception_handler
from rest_framework.exceptions import APIException


def rscc_exception_handler(exc, context):
    # Call REST framework's default exception handler first,
    # to get the standard error response.
    response = exception_handler(exc, context)

    # Now add the HTTP status code to the response.
    if response is not None:
        response.data['status_code'] = response.status_code

    return response


class APIException(APIException):
    """
    内部业务异常
    """
    status_code = 520
    default_detail = u"内部业务错误"
    default_code = 'service_error'
